﻿@using DeviceMaintainGIS.Model.DevInfo;
@{
    Layout = null;

}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>基站信息</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
    <script type="text/javascript"
            src="http://webapi.amap.com/maps?v=1.4.3&key=29dca330739166f3fa36b94ed48168ad&plugin=AMap.Autocomplete"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
    <link href="~/Scripts/jquery-easyui-1.5.4/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui-1.5.4/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui-1.5.4/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui-1.5.4/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <script src="~/Content/js/common.js"></script>
    <link href="~/Content/themes/table.css" rel="stylesheet" />
    <script type="text/javascript">
        $(function () {
            $.ajax({     //请求当前用户可以操作的按钮
                url: "/Button/GetUserAuthorizeButton?r=" + Math.random(),
                type: "post",
                data: { "KeyCode": "22", "KeyName": "Loca" },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    if (data.success) {
                        var toolbar = getToolBar(data);      //common.js
                        if (data.search) {     //判断是否有浏览权限
                            var oldSelectRoleId;   //上次点选的RoleId
                            $("#ui_user_dg").datagrid({
                                url: "/Loca/GetAllLocaInfo",
                                striped: true, rownumbers: true, pagination: true, pageSize: 20, singleSelect: true,
                                idField: 'LocaId',
                                sortName: 'UpdateTime',
                                sortOrder: 'desc',
                                pageList: [20, 40, 60, 80, 100],
                                frozenColumns: [[
                                                 { width: 100, title: '基站编号', field: 'LocaId', hidden: true },
                                                 { width: 100, title: '基站名称', field: 'LocaName' },
                                                 { width: 100, title: '基站类型', field: 'LocaTypeName' },
                                                 { width: 40, title: '安装高度', field: 'LocaHigh' },
                                                 { width: 100, title: '描述', field: 'Describe' },
                                                 {
                                                     width: 100, title: '链路方式', field: 'Link',
                                                     formatter: function (value, rec) {
                                                         if (value == 1) {
                                                             return '无线';
                                                         }
                                                         else if (value == 2) {
                                                             return "有线";
                                                         }
                                                         else if (value == 3) {
                                                             return "租用光缆";
                                                         }
                                                         else
                                                         {
                                                             return "自建光缆";
                                                         }
                                                     }

                                                 },
                                                 {
                                                     width: 100, title: '供电方式', field: 'PowerMode',
                                                     formatter: function (value, rec) {
                                                         if (value == 1) {
                                                             return '太阳能';
                                                         }
                                                         else {
                                                             return "市电";
                                                         }
                                                     }
                                                 },
                                                 { width: 100, title: '区县', field: 'District' },
                                                 { width: 100, title: '乡镇', field: 'Town' },
                                                 { width: 100, title: '海拔', field: 'Altitude' },
                                                 { width: 100, title: '周边村落', field: 'Village' },
                                                 { width: 500, title: '备注', field: 'Remark' },
                                                 { width: 100, title: '经度', field: 'Longitude', hidden: true },
                                                 { width: 100, title: '纬度', field: 'Latitude', hidden: true },
                                                 { width: 100, title: '导航经度', field: 'NaviLongitude', hidden: true },
                                                 { width: 100, title: '导航纬度', field: 'NaviLatitude', hidden: true },
                                                 { width: 100, title: '停车经度', field: 'StopLongitude', hidden: true },
                                                 { width: 100, title: '停车纬度', field: 'StopLatitude', hidden: true },

                                ]],

                                toolbar: toolbar.length == 0 ? null : toolbar,

                                onSelect: function (rowIndex, rowData) {
                                    //alert(rowData.LocaId);
                                    $("#strLocaId").val(rowData.LocaId);
                                    if (oldSelectRoleId == rowData.LocaId) {
                                        return;
                                    }
                                    oldSelectRoleId = rowData.LocaId;
                                    var $ui_role_layout = $("#ui_user_layout");
                                    var eastRoleUser = $ui_role_layout.layout("panel", "east");
                                    if (eastRoleUser.panel("options").collapsed) {   //判断是否展开
                                        $ui_role_layout.layout("expand", "east");
                                    }
                                    eastRoleUser.panel("setTitle", "基站负责人信息");
                                    if ($("#ui_role_user_dg").data("datagrid")) {
                                        $("#ui_role_user_dg").datagrid({       //请求数据
                                            url: "/Loca/GetLocaManagerByLocaId?LocaId=" + rowData.LocaId
                                        });
                                    }
                                    else {
                                        $("#ui_role_user_dg").datagrid({       //初始化datagrid
                                            url: "/Loca/GetLocaManagerByLocaId?LocaId=" + rowData.LocaId,
                                            striped: true, rownumbers: true, pagination: true, pageSize: 20, singleSelect: true,
                                            idField: 'LocaManagerId',
                                            sortName: 'CreateTime',
                                            sortOrder: 'asc',
                                            toolbar: [{ text: '添加负责人', iconCls: 'icon-add', handler: function () { addLocaManager(); } }, '-', { text: '删除负责人', iconCls: 'icon-remove', handler: function () { delLocaManager(); } }],
                                            pageList: [20, 40, 60, 80, 100],
                                            columns: [[
                                                { field: 'LocaManagerId', title: '基站负责人ID', width: 60, hidden: true },
                                                  { field: 'LocaManager', title: '基站负责人名称', width: 100 },
                                                  { field: 'Tel', title: '基站负责人名称电话', width: 120 },
                                                  {
                                                      field: 'IsLeader', title: '是否是主要负责人', sortable: true, width: 120, align: 'center',
                                                      formatter: function (value, row, index) {
                                                          if (value != null) {
                                                              return value ? '<img src="../Content/themes/icon/chk_checked.gif" alt="是" title="是" />' : '<img src="../Content/themes/icon/chk_unchecked.gif" alt="否" title="否" />';
                                                          }
                                                      }
                                                  },
                                            ]]
                                        });
                                    }
                                }

                            });
                        }
                        else {
                            $.show_alert("提示", "无权限，请联系管理员！");
                        }
                    } else {
                        $.show_alert("错误", data.result);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            })
        });

        //添加基站信息
        function AddLoca() {
            $("<div/>").dialog({
                id: "ui_user_add_dialog",
                href: "/Loca/LocaAdd",
                title: "添加基站信息",
                height: 570,
                width: 910,
                modal: true,
                buttons: [{
                    id: "ui_user_add_btn",
                    text: '添 加',
                    handler: function () {
                        if ($("#LocaType").val() == '') {
                            alert('请选择基站类型');
                            return false;
                        }
                        if ($("#Link").val() == '') {
                            alert('请选择链路方式');
                            return false;
                        }
                        if ($("#PowerMode").val() == '') {
                            alert('请选择供电方式');
                            return false;
                        }
                        //----------------经纬度
                        var txtLongitudeDegree = $("#txtLongitudeDegree").val();
                        var txtLongitudeBranch = $("#txtLongitudeBranch").val();
                        var txtLongitudeSecond = $("#txtLongitudeSecond").val();

                        var tmp = parseFloat(txtLongitudeBranch) + parseFloat(txtLongitudeSecond / 60);
                        var Longitude = parseFloat(tmp / 60) + parseFloat(txtLongitudeDegree);

                        var txtLatitudeDegree = $("#txtLatitudeDegree").val();
                        var txtLongitudeBranch = $("#txtLatitudeBranch").val();
                        var txtLatitudeSecond = $("#txtLatitudeSecond").val();

                        var tmp = parseFloat(txtLongitudeBranch) + parseFloat(txtLatitudeSecond / 60);
                        var Latitude = parseFloat(tmp / 60) + parseFloat(txtLatitudeDegree);


                        //----------------停车经纬度
                        var txtNaviLongitudeDegree = $("#txtNaviLongitudeDegree").val();
                        var txtNaviLongitudeBranch = $("#txtNaviLongitudeBranch").val();
                        var txtNaviLongitudeSecond = $("#txtNaviLongitudeSecond").val();

                        var tmp = parseFloat(txtNaviLongitudeBranch) + parseFloat(txtNaviLongitudeSecond / 60);
                        var NaviLongitude = parseFloat(tmp / 60) + parseFloat(txtNaviLongitudeDegree);

                        var txtNaviLatitudeDegree = $("#txtNaviLatitudeDegree").val();
                        var txtNaviLatitudeBranch = $("#txtNaviLatitudeBranch").val();
                        var txtNaviLatitudeSecond = $("#txtNaviLatitudeSecond").val();

                        var tmp = parseFloat(txtNaviLatitudeBranch) + parseFloat(txtNaviLatitudeSecond / 60);
                        var NaviLatitude = parseFloat(tmp / 60) + parseFloat(txtNaviLatitudeDegree);


                        //----------------导航经纬度
                        var txtStopLongitudeDegree = $("#txtStopLongitudeDegree").val();
                        var txtStopLongitudeBranch = $("#txtStopLongitudeBranch").val();
                        var txtStopLongitudeSecond = $("#txtStopLongitudeSecond").val();

                        var tmp = parseFloat(txtStopLongitudeBranch) + parseFloat(txtStopLongitudeSecond / 60);
                        var StopLongitude = parseFloat(tmp / 60) + parseFloat(txtStopLongitudeDegree);

                        var txtStopLatitudeDegree = $("#txtStopLatitudeDegree").val();
                        var txtStopLatitudeBranch = $("#txtStopLatitudeBranch").val();
                        var txtStopLatitudeSecond = $("#txtStopLatitudeSecond").val();

                        var tmp = parseFloat(txtStopLatitudeBranch) + parseFloat(txtStopLatitudeSecond / 60);
                        var StopLatitude = parseFloat(tmp / 60) + parseFloat(txtStopLatitudeDegree);





                        $("#UserAddForm").form("submit", {
                            url: "/Loca/LocaInfoAdd",
                            onSubmit: function (param) {
                                param.LocaName = $("#txtLocaName").val();
                                param.LocaTypeId = $("#LocaType").val();
                                param.LocaHigh = $("#txtLocaHigh").val();
                                param.Describe = $("#txtDescribe").val();
                                param.Link = $("#Link").val();
                                param.PowerMode = $("#PowerMode").val();
                                param.District = $("#txtDistrict").val();
                                param.Town = $("#txtTown").val();
                                param.Longitude = Longitude; //$("#txtLongitude").val();
                                param.Latitude = Latitude;//$("#txtLatitude").val();
                                param.Altitude = $("#txtAltitude").val();
                                param.NaviLongitude = NaviLongitude;//$("#txtNaviLongitude").val();
                                param.NaviLatitude = NaviLatitude;//$("#txtNaviLatitude").val();
                                param.StopLongitude = StopLongitude;//$("#txtStopLongitude").val();
                                param.StopLatitude = StopLatitude;//$("#txtStopLatitude").val();
                                param.Village = $("#txtVillage").val();
                                param.Remark = $("#txtRemark").val();
                                if ($(this).form('validate')) {
                                    $('#ui_user_add_btn').linkbutton('disable');
                                    return true;
                                }
                                else {
                                    $('#ui_user_add_btn').linkbutton('enable');   //恢复按钮
                                    return false;
                                }
                            },
                            success: function (data) {
                                var dataJson = eval('(' + data + ')');
                                if (dataJson.success) {
                                    $("#ui_user_add_dialog").dialog('destroy');
                                    $.show_alert("提示", dataJson.msg);
                                    $("#ui_user_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $('#ui_user_add_btn').linkbutton('enable');
                                    $.show_alert("提示", dataJson.msg);
                                }
                            }
                        });
                    }
                }, {
                    text: '取 消',
                    handler: function () {
                        $("#ui_user_add_dialog").dialog('destroy');
                    }
                }],
                onLoad: function () {
                    $("#txtUserIDAdd").focus();
                },
                onClose: function () {
                    $("#ui_user_add_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }

        //修改基站信息
        function EditLoca() {
            var rows = $("#ui_user_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先选择要修改的基站");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量修改基站");
                $("#ui_user_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            var id = "";
            $.each(rows, function (i, row) {
                id += row.LocaId + ",";
            });

            id = id.substring(0, id.length - 1);
            //alert(id);
            $("<div/>").dialog({
                id: "ui_loca_edit_dialog",
                href: "/Loca/LocaEdit?LocaId=" + id,
                title: "修改基站信息",
                height: 570,
                width: 910,
                modal: true,
                buttons: [{
                    id: "ui_user_edit_btn",
                    text: '修 改',
                    handler: function () {
                        if (Verification() == false) {
                            //alert('111');
                            return;
                        }
                        //----------------经纬度
                        var txtLongitudeDegree = $("#txtLongitudeDegree").val();
                        var txtLongitudeBranch = $("#txtLongitudeBranch").val();
                        var txtLongitudeSecond = $("#txtLongitudeSecond").val();

                        var tmp = parseFloat(txtLongitudeBranch) + parseFloat(txtLongitudeSecond / 60);
                        var Longitude = parseFloat(tmp / 60) + parseFloat(txtLongitudeDegree);

                        var txtLatitudeDegree = $("#txtLatitudeDegree").val();
                        var txtLongitudeBranch = $("#txtLatitudeBranch").val();
                        var txtLatitudeSecond = $("#txtLatitudeSecond").val();

                        var tmp = parseFloat(txtLongitudeBranch) + parseFloat(txtLatitudeSecond / 60);
                        var Latitude = parseFloat(tmp / 60) + parseFloat(txtLatitudeDegree);


                        //----------------停车经纬度
                        var txtNaviLongitudeDegree = $("#txtNaviLongitudeDegree").val();
                        var txtNaviLongitudeBranch = $("#txtNaviLongitudeBranch").val();
                        var txtNaviLongitudeSecond = $("#txtNaviLongitudeSecond").val();

                        var tmp = parseFloat(txtNaviLongitudeBranch) + parseFloat(txtNaviLongitudeSecond / 60);
                        var NaviLongitude = parseFloat(tmp / 60) + parseFloat(txtNaviLongitudeDegree);

                        var txtNaviLatitudeDegree = $("#txtNaviLatitudeDegree").val();
                        var txtNaviLatitudeBranch = $("#txtNaviLatitudeBranch").val();
                        var txtNaviLatitudeSecond = $("#txtNaviLatitudeSecond").val();

                        var tmp = parseFloat(txtNaviLatitudeBranch) + parseFloat(txtNaviLatitudeSecond / 60);
                        var NaviLatitude = parseFloat(tmp / 60) + parseFloat(txtNaviLatitudeDegree);


                        //----------------导航经纬度
                        var txtStopLongitudeDegree = $("#txtStopLongitudeDegree").val();
                        var txtStopLongitudeBranch = $("#txtStopLongitudeBranch").val();
                        var txtStopLongitudeSecond = $("#txtStopLongitudeSecond").val();

                        var tmp = parseFloat(txtStopLongitudeBranch) + parseFloat(txtStopLongitudeSecond / 60);
                        var StopLongitude = parseFloat(tmp / 60) + parseFloat(txtStopLongitudeDegree);

                        var txtStopLatitudeDegree = $("#txtStopLatitudeDegree").val();
                        var txtStopLatitudeBranch = $("#txtStopLatitudeBranch").val();
                        var txtStopLatitudeSecond = $("#txtStopLatitudeSecond").val();

                        var tmp = parseFloat(txtStopLatitudeBranch) + parseFloat(txtStopLatitudeSecond / 60);
                        var StopLatitude = parseFloat(tmp / 60) + parseFloat(txtStopLatitudeDegree);
                        $("#LocaEditForm").form("submit", {
                            url: "/Loca/LocaInfoEdit",
                            onSubmit: function (paramLoca) {
                                paramLoca.LocaId = $("#txtLocaId").val();
                                paramLoca.LocaName = $("#txtLocaName").val();
                                paramLoca.LocaTypeId = $("#LocaType").val();
                                paramLoca.LocaHigh = $("#txtLocaHigh").val();
                                paramLoca.Describe = $("#txtDescribe").val();
                                paramLoca.Link = $("#Link").val();
                                paramLoca.PowerMode = $("#PowerMode").val();
                                paramLoca.District = $("#txtDistrict").val();
                                paramLoca.Town = $("#txtTown").val();
                                //paramLoca.Longitude = $("#txtLongitude").val();
                                //paramLoca.Latitude = $("#txtLatitude").val();
                                //paramLoca.Altitude = $("#txtAltitude").val();
                                //paramLoca.NaviLongitude = $("#txtNaviLongitude").val();
                                //paramLoca.NaviLatitude = $("#txtNaviLatitude").val();
                                //paramLoca.StopLongitude = $("#txtStopLongitude").val();
                                //paramLoca.StopLatitude = $("#txtStopLatitude").val();
                                paramLoca.Longitude = Longitude; //$("#txtLongitude").val();
                                paramLoca.Latitude = Latitude;//$("#txtLatitude").val();
                                paramLoca.Altitude = $("#txtAltitude").val();
                                paramLoca.NaviLongitude = NaviLongitude;//$("#txtNaviLongitude").val();
                                paramLoca.NaviLatitude = NaviLatitude;//$("#txtNaviLatitude").val();
                                paramLoca.StopLongitude = StopLongitude;//$("#txtStopLongitude").val();
                                paramLoca.StopLatitude = StopLatitude;//$("#txtStopLatitude").val();
                                paramLoca.Village = $("#txtVillage").val();
                                paramLoca.Remark = $("#txtRemark").val();
                                if ($(this).form('validate')) {
                                    $('#ui_user_edit_btn').linkbutton('disable');
                                    return true;
                                }
                                else {
                                    $('#ui_user_edit_btn').linkbutton('enable');   //恢复按钮
                                    return false;
                                }
                            },
                            success: function (data) {
                                var dataJson = eval('(' + data + ')');
                                if (dataJson.success) {
                                    $("#ui_loca_edit_dialog").dialog('destroy');
                                    $.show_alert("提示", dataJson.msg);
                                    $("#ui_user_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $('#ui_user_edit_btn').linkbutton('enable');
                                    $.show_alert("提示", dataJson.msg);
                                }
                            }
                        });
                    }
                }, {
                    text: '取 消',
                    handler: function () {
                        $("#ui_loca_edit_dialog").dialog('destroy');
                    }
                }],
                onLoad: function () {

                    $("#Link").val(rows[0].Link);
                    $("#PowerMode").val(rows[0].PowerMode);
                    alert(rows[0].Longitude);
                    var txtLongitude = Math.abs(rows[0].Longitude);
                    var txtLongitudeDegree = Math.floor(txtLongitude);//度
                    var txtLongitudeBranch = Math.floor((txtLongitude - txtLongitudeDegree) * 60);//分
                    var txtLongitudeSecond = Math.round((txtLongitude - txtLongitudeDegree) * 3600 % 60);//秒
                    $("#txtLongitudeDegree").val(txtLongitudeDegree);//度
                    $("#txtLongitudeBranch").val(txtLongitudeBranch);//分
                    $("#txtLongitudeSecond").val(txtLongitudeSecond);//秒

                    var Latitude = Math.abs(rows[0].Latitude);
                    var txtLatitudeDegree = Math.floor(Latitude);//度
                    var txtLatitudeBranch = Math.floor((Latitude - txtLatitudeDegree) * 60);//分
                    var txtLatitudeSecond = Math.round((Latitude - txtLatitudeDegree) * 3600 % 60);//秒
                    $("#txtLatitudeDegree").val(txtLatitudeDegree);//度
                    $("#txtLatitudeBranch").val(txtLatitudeBranch);//分
                    $("#txtLatitudeSecond").val(txtLatitudeSecond);//秒

                    //var du = document.getElementById("input_du").value;
                    //var str1 = du.split(".");
                    //var du1 = str1[0];
                    //var tp = "0." + str1[1]
                    //var tp = String(tp * 60);		//这里进行了强制类型转换
                    //var str2 = tp.split(".");
                    //var fen = str2[0];
                    //tp = "0." + str2[1];
                    //tp = tp * 60;
                    //var miao = tp;
                    //document.getElementById("calculated_DFM").innerHTML = du1 + "°" + fen + "'" + miao + "\"";

                    //var d = document.getElementById("input_dfm1").value;
                    //var f = document.getElementById("input_dfm2").value;
                    //var m = document.getElementById("input_dfm3").value;

                    //var f = parseFloat(f) + parseFloat(m / 60);
                    //var du = parseFloat(f / 60) + parseFloat(d);
                    //document.getElementById("calculated_du").innerHTML = du;

                    alert(rows[0].NaviLongitude);
                    var NaviLongitude = Math.abs(rows[0].NaviLongitude);
                    var txtNaviLongitudeDegree = Math.floor(NaviLongitude);//度
                    var txtNaviLongitudeBranch = Math.floor((NaviLongitude - txtNaviLongitudeDegree) * 60);//分
                    var txtNaviLongitudeSecond = Math.round((NaviLongitude - txtNaviLongitudeDegree) * 3600 % 60);//秒
                    $("#txtNaviLongitudeDegree").val(txtNaviLongitudeDegree);//度
                    $("#txtNaviLongitudeBranch").val(txtNaviLongitudeBranch);//分
                    $("#txtNaviLongitudeSecond").val(txtNaviLongitudeSecond);//秒

                    var NaviLatitude = Math.abs(rows[0].NaviLatitude);
                    var txtNaviLatitudeDegree = Math.floor(NaviLatitude);//度
                    var txtNaviLatitudeBranch = Math.floor((NaviLatitude - txtNaviLatitudeDegree) * 60);//分
                    var txtNaviLatitudeSecond = Math.round((NaviLatitude - txtNaviLatitudeDegree) * 3600 % 60);//秒
                    $("#txtNaviLatitudeDegree").val(txtNaviLatitudeDegree);//度
                    $("#txtNaviLatitudeBranch").val(txtNaviLatitudeBranch);//分
                    $("#txtNaviLatitudeSecond").val(txtNaviLatitudeSecond);//秒



                    alert(rows[0].StopLongitude);
                    var StopLongitude = Math.abs(rows[0].StopLongitude);
                    var txtStopLongitudeDegree = Math.floor(StopLongitude);//度
                    var txtStopLongitudeBranch = Math.floor((StopLongitude - txtStopLongitudeDegree) * 60);//分
                    var txtStopLongitudeSecond = Math.round((StopLongitude - txtStopLongitudeDegree) * 3600 % 60);//秒
                    $("#txtStopLongitudeDegree").val(txtStopLongitudeDegree);//度
                    $("#txtStopLongitudeBranch").val(txtStopLongitudeBranch);//分
                    $("#txtStopLongitudeSecond").val(txtStopLongitudeSecond);//秒

                    var StopLatitude = Math.abs(rows[0].StopLatitude);
                    var txtStopLatitudeDegree = Math.floor(StopLatitude);//度
                    var txtStopLatitudeBranch = Math.floor((StopLatitude - txtStopLatitudeDegree) * 60);//分
                    var txtStopLatitudeSecond = Math.round((StopLatitude - txtStopLatitudeDegree) * 3600 % 60);//秒
                    $("#txtStopLatitudeDegree").val(txtStopLatitudeDegree);//度
                    $("#txtStopLatitudeBranch").val(txtStopLatitudeBranch);//分
                    $("#txtStopLatitudeSecond").val(txtStopLatitudeSecond);//秒



                },
                onClose: function () {
                    $("#ui_loca_edit_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }

        //删除基站信息
        function DelLoca() {
            var rows = $("#ui_user_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先选择要删除的基站");
                return;
            }
            $.messager.confirm('提示', '删除基站信息时会同时删除该基站所有负责人，确认删除选中行吗？', function (r) {
                if (r) {
                    var parmIds = "";
                    $.each(rows, function (i, row) {
                        parmIds += row.LocaId + ",";
                    });

                    parmIds = parmIds.substring(0, parmIds.length - 1);
                    $.ajax({
                        url: "/Loca/DelLocaInfo",
                        data: {
                            LocaId: parmIds
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_user_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                //$("#ui_user_dg")
                                $("#ui_user_layout").layout("collapse", "east");
                                //$('#cc').layout('collapse', 'east');
                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }

        //添加基站责任人信息
        function addLocaManager() {
            $("<div/>").dialog({
                id: "ui_LocaManager_add_dialog",
                href: "/Loca/LocaManagerAdd",
                title: "添加基站负责人信息",
                height: 470,
                width: 410,
                modal: true,
                buttons: [{
                    id: "ui_LocaManager_add_btn",
                    text: '添 加',
                    handler: function () {
                        var selIsLeader = document.getElementById("selIsLeader").checked;
                        var tmp = "1";
                        if (selIsLeader == false) {

                            $.ajax({
                                type: "POST",
                                async: false,
                                url: "/Loca/LocaManagerIsLeader",
                                data: {
                                    LocaId: $("#strLocaId").val(),
                                },
                                success: function (data) {
                                    var dataJson = eval('(' + data + ')');
                                    if (dataJson.msg == "0") {
                                        alert('基站无主要负责人，请勾选主要负责人，否则无法添加负责人信息');
                                        tmp = "2"
                                    }
                                }
                            });

                        }
                        if (tmp == "2") {
                            return;
                        }
                        $.ajax({
                            type: "POST",
                            url: "/Loca/LocaManagerInfoAdd",
                            data: {
                                LocaId: $("#strLocaId").val(),
                                LocaManager: $("#txtLocaManager").val(),
                                Tel: $("#txtTel").val(),
                                IsLeader: selIsLeader

                            },
                            success: function (data) {
                                var dataJson = eval('(' + data + ')');
                                if (dataJson.success) {
                                    $("#ui_LocaManager_add_dialog").dialog('destroy');
                                    $.show_alert("提示", dataJson.msg);
                                    $("#ui_role_user_dg").datagrid("reload");
                                } else {
                                    $('#ui_LocaManager_add_btn').linkbutton('enable');
                                    $.show_alert("提示", dataJson.msg);
                                }
                            }
                        });
                    }
                }, {
                    text: '取 消',
                    handler: function () {
                        $("#ui_LocaManager_add_dialog").dialog('destroy');
                    }
                }],
                onLoad: function () {
                    $("#txtUserIDAdd").focus();
                },
                onClose: function () {
                    $("#ui_LocaManager_add_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }

        //删除基站责任人信息
        function delLocaManager() {
            var rows = $("#ui_role_user_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先选择要删除的责任人");
                return;
            }
            $.messager.confirm('提示', '确定删除选中行吗？', function (r) {
                if (r) {
                    var parmIds = "";
                    var IsLeader = "";
                    $.each(rows, function (i, row) {
                        parmIds += row.LocaManagerId + ",";
                        IsLeader = row.IsLeader;
                    });
                    if (IsLeader == true) {
                        alert('因为没有设置其他负责人为主负责人，所以此条无法删除');
                        return;
                    }

                    parmIds = parmIds.substring(0, parmIds.length - 1);
                    $.ajax({
                        url: "/Loca/DelLocaManager",
                        data: {
                            LocaManagerId: parmIds
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_role_user_dg").datagrid("reload");
                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }


        function ui_user_searchdata() {
            $("#ui_user_dg").datagrid('load', {
                selLocaName: $('#selLocaName').val(),
                selDistrict: $('#selDistrict').val(),
                selTown: $('#selTown').val(),
            });
            $("#ui_user_dg").datagrid('clearSelections').datagrid('clearChecked');
        }

        function ui_user_cleardata() {
            $('#selLocaName').val(''),
            $('#selDistrict').val(''),
            $('#selTown').val(''),

            $("#ui_user_dg").datagrid('clearSelections').datagrid('clearChecked');
        }

        //扩展combox验证，easyui原始只验证select text的值，不支持value验证
        $.extend($.fn.validatebox.defaults.rules, {
            comboxValidate: {
                validator: function (value, param, missingMessage) {
                    if ($('#' + param).combobox('getValue') != '' && $('#' + param).combobox('getValue') != null) {
                        return true;
                    }
                    return false;
                },
                message: "{1}"
            }
        });
        //添加页面验证下拉列表
        function Verification() {
            //alert($("#Link").val());
            if ($("#LocaType").val() == '') {
                alert('请选择基站类型');
                return false;
            }
            if ($("#Link").val() == '') {
                alert('请选择链路方式');
                return false;
            }
            if ($("#PowerMode").val() == '') {
                alert('请选择供电方式');
                return false;
            }
            //alert($("#txtLongitude").val());
            //alert(/^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,6})?$/.test($("#txtLongitude").val()));
            //alert(/^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,6})?$/.test($("#txtNaviLongitude").val()));
            //alert(/^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,6})?$/.test($("#txtStopLongitude").val()));

            //var longitude = $("#txtLongitude").val();
            //var latitude = $("#txtLatitude").val();
            //var lon = /^-?((0|[1-9]\d?|1[1-7]\d)(\.\d{1,7})?|180(\.0{1,7})?)?$/;
            //var lat = /^-?((0|[1-8]\d|)(\.\d{1,7})?|90(\.0{1,7})?)?$/;
            //var lonRe = new RegExp(lon);
            //var latRe = new RegExp(lat);
            //alert(lonRe.test(longitude));//返回true OR  false
            //if (!lonRe.test(longitude)) {
            //    alert("经度不符合规范：经度整数部分为0-180,小数部分为0-6位！");
            //    return false;
            //}

            //if (!latRe.test(latitude)) {
            //    alert("纬度不符合规范：纬度整数部分为0-90,小数部分为0-6位！！");
            //    return false;
            //}





            if (/^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,10})?$/.test($("#txtLongitude").val()) == false)
            {
                alert('经度格式不正确');
                return false;
            }
            if (/^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,10})?$/.test($("#txtNaviLongitude").val()) == false) {
                alert('导航经度格式不正确');
                return false;
            }
            if (/^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,10})?$/.test($("#txtStopLongitude").val()) == false) {
                alert('停车经度格式不正确');
                return false;
            }

            if (/^-?(([1-8]\d?)|([1-8]\d)|90)(\.\d{1,10})?$/.test($("#txtLatitude").val()) == false) {
                alert('纬度格式不正确');
                return false;
            }
            if (/^-?(([1-8]\d?)|([1-8]\d)|90)(\.\d{1,10})?$/.test($("#txtNaviLatitude").val()) == false) {
                alert('导航纬度格式不正确');
                return false;
            }
            if (/^-?(([1-8]\d?)|([1-8]\d)|90)(\.\d{1,10})?$/.test($("#txtStopLatitude").val()) == false) {
                alert('停车纬度格式不正确');
                return false;
            }
        }

        //经纬度验证
        $.extend($.fn.validatebox.defaults.rules, {
            checkLongitude: {
                validator: function (value) {
                    //alert(value + '-checkLongitude-' + /^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,6})?$/.test(value));
                    return /^-?(([1-9]\d?)|(1[1-7]\d)|180)(\.\d{1,10})?$/.test(value);
                },
                message: '经度格式不正确'
            },
            checkLatitude: {
                validator: function (value) {
                    //alert(value + '-checkLatitude-' + /^-?(([1-8]\d?)|([1-8]\d)|90)(\.\d{1,6})?$/.test(value));
                    return /^-?(([1-8]\d?)|([1-8]\d)|90)(\.\d{1,10})?$/.test(value);
                },
                message: '纬度格式不正确'
            }
        });
        //地图拾取坐标
        function MapPickup(data) {
            $("<div/>").dialog({
                id: "ui_MapPickup_dialog",
                href: "/Map/Index",
                title: "地图拾取",
                height: 570,
                width: 910,
                modal: true,
                buttons: [{
                    id: "ui_MapPickup_btn",
                    text: '确 定',
                    handler: function () {
                        alert($("#lnglat").val());

                        var arr = $("#lnglat").val().split(',');
                        if (data == '1') {

                            value = Math.abs(arr[0]);
                            var v1 = Math.floor(value);//度
                            var v2 = Math.floor((value - v1) * 60);//分
                            var v3 = Math.round((value - v1) * 3600 % 60);//秒
                            $("#txtLongitudeDegree").val(v1);//度
                            $("#txtLongitudeBranch").val(v2);//分
                            $("#txtLongitudeSecond").val(v3);//秒

                            $("#txtLongitude").val(arr[0]);

                            value1 = Math.abs(arr[1]);
                            var v11 = Math.floor(value1);//度
                            var v22 = Math.floor((value1 - v11) * 60);//分
                            var v33 = Math.round((value1 - v11) * 3600 % 60);//秒
                            $("#txtLatitudeDegree").val(v11);//度
                            $("#txtLatitudeBranch").val(v22);//分
                            $("#txtLatitudeSecond").val(v33);//秒
                            $("#txtLatitude").val(arr[1]);

                        }
                        if (data == '2') {

                            value = Math.abs(arr[0]);
                            var v1 = Math.floor(value);//度
                            var v2 = Math.floor((value - v1) * 60);//分
                            var v3 = Math.round((value - v1) * 3600 % 60);//秒
                            $("#txtNaviLongitudeDegree").val(v1);//度
                            $("#txtNaviLongitudeBranch").val(v2);//分
                            $("#txtNaviLongitudeSecond").val(v3);//秒
                            $("#txtNaviLongitude").val(arr[0]);

                            value1 = Math.abs(arr[1]);
                            var v11 = Math.floor(value1);//度
                            var v22 = Math.floor((value1 - v11) * 60);//分
                            var v33 = Math.round((value1 - v11) * 3600 % 60);//秒
                            $("#txtNaviLatitudeDegree").val(v11);//度
                            $("#txtNaviLatitudeBranch").val(v22);//分
                            $("#txtNaviLatitudeSecond").val(v33);//秒
                            $("#txtNaviLatitude").val(arr[1]);
                        }
                        if (data == '3') {

                            value = Math.abs(arr[0]);
                            var v1 = Math.floor(value);//度
                            var v2 = Math.floor((value - v1) * 60);//分
                            var v3 = Math.round((value - v1) * 3600 % 60);//秒
                            $("#txtStopLongitudeDegree").val(v1);//度
                            $("#txtStopLongitudeBranch").val(v2);//分
                            $("#txtStopLongitudeSecond").val(v3);//秒
                            $("#txtStopLongitude").val(arr[0]);

                            value1 = Math.abs(arr[1]);
                            var v11 = Math.floor(value1);//度
                            var v22 = Math.floor((value1 - v11) * 60);//分
                            var v33 = Math.round((value1 - v11) * 3600 % 60);//秒
                            $("#txtStopLatitudeDegree").val(v11);//度
                            $("#txtStopLatitudeBranch").val(v22);//分
                            $("#txtStopLatitudeSecond").val(v33);//秒
                            $("#txtStopLatitude").val(arr[1]);
                        }
                        $("#ui_MapPickup_dialog").dialog('destroy');
                    }
                }, {
                    text: '取 消',
                    handler: function () {
                        $("#ui_MapPickup_dialog").dialog('destroy');
                    }
                }],
                onLoad: function () {

                },
                onClose: function () {
                    $("#ui_MapPickup_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }

    </script>


</head>
<body>
    <div id="ui_user_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'north',split:true,border:true,collapsed:false" title="搜索条件" style="height:74px;">
            <div id="ui_user_search">
                <table class="tableForm" style="width: 99%; height: 100%; background: #F5F5F5;">
                    <tr>
                        <th>
                            基站名称：
                        </th>
                        <td>
                            <input name="selLocaName" id="selLocaName" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            区县：
                        </th>
                        <td>
                            <input name="selDistrict" id="selDistrict" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>
                        <th>
                            乡镇：
                        </th>
                        <td>
                            <input name="selTown" id="selTown" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>
                        <td>
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" plain="true"
                               onclick="ui_user_searchdata();">搜索</a>
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-clear" plain="true"
                               onclick="ui_user_cleardata();">清空条件</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        @*<div data-options="region:'east',split:true,border:true,collapsed:true" title="角色成员"
             style="width: 480px;">
            <table id="ui_role_user_dg" data-options="fit:true,border:false"></table>
        </div>*@
        <div data-options="region:'center',border:false" >
            <table id="ui_user_dg" data-options="fit:true,border:false"  ></table>
        </div>
    </div>
    <input type="hidden" name="strLocaId" id="strLocaId" value="">
</body>
</html>
